//  Copyright 2011 Charlie Garrett
//
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//  http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
//
//  main.cpp
//

#include "logic.h"

// Treat initial -F arguments as flags and the next argument as
// the sole input file.
int main (int argc, const char * argv[]) {
    std::cout << "Testing Prolog Interpreter" << std::endl;

    bool trace = false;
    bool interactive = false;
    int arg_num = 1;
    while (argc > arg_num && argv[arg_num][0] == '-') {
        char flag = argv[arg_num++][1];
        switch (flag) {
            case 't':
                std::cout << "Trace execution" << std::endl;
                trace = true;
                break;
            case 'i':
                std::cout << "Interactive execution" << std::endl;
                interactive = true;
                break;
            default:
                std::cout << "Flag -" << flag << " not recognized" << std::endl;
                break;
        }
    }
    if (argc > 1) {
        logic::InterpretProgram(argv[arg_num], trace, interactive);
    } else {
        std::cout << "No input files specified" << std::endl;
    }
    return 0;
}

